fix(npu): serialize kernel registry access#2
Draft
pjgao wants to merge 1 commit into
Draft
Conversation
This was referenced Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动概述
对进程级 NPU
KernelRegistry的读取、注册和清理进行串行化。修改原因
KernelRegistry是进程级 singleton,Triton NPU 算子采用先查询、再按需注册的懒加载方式。多个线程并发首次调用不同或相同 kernel 时,可能同时读写kernel_infos_;C++ 容器的并发读写属于未定义行为。本修改在注册、查询 workspace、获取 stub 和清理入口使用同一把进程级互斥锁,保证 registry 内部状态的一致性。该问题与具体模型和 MegaMoe 无关,属于通用的 Triton NPU runtime 线程安全修复。
验证结果与边界
本 PR 不修复 MegaMoe 跨 rank 随机 token 问题,也不应以 MegaMoe 精度结果作为直接验证证据。
下游依赖